package com.${projectName}.${moduleName}.rest.${packageName}.transfer;

import com.baomidou.mybatisplus.core.toolkit.CollectionUtils;
import com.hkbt.base.frame.domain.bo.PageBO;
import com.hkbt.base.frame.domain.vo.PageVO;
import com.hkbt.base.frame.objectTransform.BaseBO2VOTransfer;
import com.${projectName}.${moduleName}.rest.${packageName}.restful.vo.${tableName}RVO;
import com.${projectName}.${moduleName}.service.${packageName}.bo.${tableName}BO;
import com.${projectName}.${moduleName}.service.${packageName}.service.${tableName}Service;

import org.springframework.stereotype.Service;
import javax.annotation.Resource;
import java.util.Collections;
import java.util.List;

/**
 * ${comment}BOToVO
 */
@Service
public class ${tableName}BOToVO {

    private BaseBO2VOTransfer<${tableName}BO, ${tableName}RVO> ${lowerTableName}Web = new BaseBO2VOTransfer<>(${tableName}RVO.class);

    @Resource
    private ${tableName}Service ${lowerTableName}Service;

    public ${tableName}RVO toVO(${tableName}BO bo){
        ${tableName}RVO vo = ${lowerTableName}Web.toVO(bo);
        return vo;
    }

    public List<${tableName}RVO> toVos(List<${tableName}BO> boList){
       if (CollectionUtils.isEmpty(boList)) {
           return Collections.EMPTY_LIST;
       }
       List<${tableName}RVO> voList = ${lowerTableName}Web.listVO(boList);
       return voList;
    }

    public PageVO<${tableName}RVO> toPage(PageBO<${tableName}BO> pageBO){
       PageVO<${tableName}RVO> pageVO = ${lowerTableName}Web.pageVO(pageBO);
       pageVO.setRows(toVos(pageBO.getRows()));
       return pageVO;
    }


}
